
let goods = document.querySelector('#goods')

function render(data, el) {
    console.log(data,el);
    data.forEach(item => {
        let li = document.createElement('li')
        let regExp = /(?<=imgurl=)[^'"]*/
        let result = item.productImg2.match(regExp)
        let html = `
        <a href='detail.html?productid=${item.productId}'}>
        <img width="100" src="${result}" alt="">
        <div id="top">
            <h4>
                <b>${item.productName}</b>
                <span>${item.productPinkage}</span>
            </h4>
        </div>
        <div id="bottn">
            <span>${item.productFrom} |</span>
            <span>${item.productTime}</span>
            <span id="ic">
                <img src="./../assets/imges/信息.png"></img>
                <i>${item.productComCount}</i>
            </apan>
        </div>
          </a>

        `
        li.innerHTML = html

        el.appendChild(li)

    });

}

function getData(pageid = 0) {

    fetch(`http://chst.vip:1234/api/getmoneyctrl?pageid=${pageid}`)
        .then(body => body.json())
        .then(res => {
            // console.log(res);
            render(res.result, goods)
        })
}
getData()

let pageid = 0
lazyLoad(function () {
    pageid++
    if (pageid > 14) {
        return
    }
    getData(pageid)

}, 200)


